package com.woniuxy.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.SecurityUtils;
import com.woniuxy.entity.UserDaikuanDate;
import com.woniuxy.entity.UserYewuDate;
import com.woniuxy.service.MyUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.sql.Date;
import java.util.List;

@RestController
@RequestMapping("/myuser")
public class MyUserController extends BaseController {
    @Autowired
    MyUserService myuserService;

    @GetMapping("/listyewu")
    public TableDataInfo listyewu(){
        startPage();
        int user_id = Math.toIntExact(SecurityUtils.getUserId());
        List<UserYewuDate> list = myuserService.listyewu(user_id);
        return getDataTable(list) ;
    }

    @GetMapping("/listdaikuan")
    public TableDataInfo listdaikuan(){
        startPage();
        int user_id = Math.toIntExact(SecurityUtils.getUserId());
        List<UserDaikuanDate> list = myuserService.listdaikuan(user_id);
        return getDataTable(list) ;
    }

    @GetMapping("/querydaikuan/{datas}")
    public TableDataInfo querydaikuan(@PathVariable("datas") Date[] datas){
        startPage();
        int id = Math.toIntExact(SecurityUtils.getUserId());
        List<UserDaikuanDate> list = myuserService.querydaikuan(datas,id);
        return getDataTable(list) ;
    }

    @GetMapping("/queryyewu/{datas}")
    public TableDataInfo queryyewu(@PathVariable("datas") Date[] datas){
        startPage();
        int id = Math.toIntExact(SecurityUtils.getUserId());
        List<UserYewuDate> list = myuserService.queryyewu(datas,id);
        return getDataTable(list) ;
    }
}
